﻿using Nasty.Core.LoadParams;
using Nasty.Core.Registry;
using Quartz;
using SqlSugar;

namespace Nasty.QuartzModule
{
    [DisallowConcurrentExecution]
    public class TestJob : AutofacJob
    {
        private readonly ILogger<TestJob> _logger;
        private readonly SqlSugarClient _client;

        // 依赖注入可以通过构造函数进行
        public TestJob(ILogger<TestJob> logger, SqlSugarClient client)
        {
            _logger = logger;
            _client = client;
        }

        public override ResultData<string> Execute(object task, IJobExecutionContext context)
        {
            var jobKey = context.JobDetail.Key;
            Console.WriteLine($"{jobKey.Name}:{DateTime.Now}");
            return new ResultData<string>() { IsSuccess = true, Message = "Yes" };
        }

        //public Task Execute(IJobExecutionContext context)
        //{
        //    var jobKey = context.JobDetail.Key;
        //    Console.WriteLine($"{jobKey.Name}:{DateTime.Now}");
        //    return Task.CompletedTask;
        //}



    }
}
